package second;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.*;
import java.util.*;
import java.nio.file.*;
public class readFile {
    public static void main(String[] args){
        String token="";
        Path path= Paths.get("E:\\data.txt");
        try(InputStream input=Files.newInputStream(path, StandardOpenOption.READ);
            Scanner sc=new Scanner(input)){
            while(sc.hasNext()){
                token +=sc.next()+" ";
            }
        }catch(IOException e){
            e.printStackTrace();
        }
        String[] str=token.split("[ ,.]");
        Set<String> hs=new HashSet<>();
        Set<String> se=new HashSet<>();
        for(String s:str){
            if(!hs.add(s)){
                se.add(s);
            }
        }
        System.out.println("不同的单词为:"+hs);
        System.out.print("重复的单词为:"+se);
    }
}


